# -*- coding: utf-8 -*-

from odoo import models, fields, api


class Location(models.Model):
    _inherit = "stock.location"
    _rec_name = 'name'
    ship_contact = fields.Char(string='联系人')
    ship_phone = fields.Char(string='电话')
    purchase_order_ids=fields.One2many('purchase.order','boat_location_id')
    boat_partner_ids=fields.One2many('res.partner',compute='compute_partner_ids')
    dest_name=fields.Char(string='目的地')
    dw=fields.Char(string=u'吨位（吨）')

    location_id=fields.Many2one('stock.location',default=7)

    def compute_partner_ids(self):
        for record in self:
            if record.purchase_order_ids.mapped('partner_id'):
                record.boat_partner_ids=record.purchase_order_ids.mapped('partner_id')[0].ids
            else:
                record.boat_partner_ids=False